<template>
    <div>
        <TableHead
            :config="tableHeaderConfig"
            :searchdata.sync="filters"
            @parentPageList="findPage()"
            :tabinline="true"
            v-show="showSearch"
        ></TableHead>
        <el-card class="card-box">
            <TableToolBar :showSearch.sync="showSearch" @queryTable="findPage" :columns="columns"></TableToolBar>
            <Table
                v-model="pageRequest.pageNum"
                :data="dataList"
                :total="total"
                :columns="columns"
                :loading="loading"
                :showNo="true"
            ></Table>
        </el-card>
    </div>
</template>
<script>
import { fetLogOper } from '@/api/system/log'
import TableToolBar from '@/components/TableToolBar'
export default {
    name: 'logoper',
    components: {
        TableToolBar
    },
    data() {
        return {
            loading: false,
            showSearch: true,
            pageRequest: { pageNum: 1, pageSize: 10 },
            filters: { operName: '', date: '', title: '', status: '' },
            tableHeaderConfig: [
                { title: '操作人', code: 'operName', type: 'input' },
                { title: '模块', code: 'title', type: 'input' },
                {
                    title: '业务类型',
                    code: 'businessType',
                    type: 'select',
                    options: [
                        {
                            label: '新增',
                            value: '1'
                        },
                        {
                            label: '修改',
                            value: '2'
                        },
                        {
                            label: '删除',
                            value: '3'
                        },
                        {
                            label: '其他',
                            value: '0'
                        }
                    ]
                },
                {
                    title: '状态',
                    code: 'status',
                    type: 'select',
                    options: [
                        {
                            label: '正常',
                            value: '0'
                        },
                        {
                            label: '异常',
                            value: '1'
                        }
                    ]
                },
                { title: '日期', code: 'date', type: 'datetimerange' }
            ],

            // 表格的列参配置
            columns: [
                { prop: 'operName', label: '操作人', minWidth: 100, visible: true, key: 'operName' },
                { prop: 'title', label: '模块', minWidth: 100, visible: true, key: 'title' },
                { prop: 'operUrl', label: '请求url', minWidth: 120, visible: true, key: 'operUrl' },
                { prop: 'operParam', label: '请求参数', minWidth: 100, visible: true, key: 'operParam' },
                { prop: 'operatorType', label: '类别', minWidth: 100, visible: true, key: 'operatorType' }
            ],
            dataList: [],
            total: 0
        }
    },
    methods: {
        findPage() {
            const params = Object.assign({}, this.pageRequest, this.filters)
            console.log('params', params)
            fetLogOper(params).then((res) => {
                console.log(res)
                this.total = res.data.total
                this.dataList = res.data.items
            })
        }
    },
    mounted() {
        this.findPage()
    }
}
</script>
